<?php
class retrieve_files extends retrieve_base{

	private $module_display_options 	= array();
	
	/**
	* function produces abstract structure of modules db structure
	*
    * used to generate the table structure required abstract function that passes an abstract
	* representation of the desired table structure to the proper database module which will
	* interpet the abstract and convert it into a valid SQL Create table structure.
	*
	* @return Array list of abstract table definitions for this module
	*/
	function create_table(){
		$tables = array();
		/**
		* Table structure for table 'File_info'
		*/
		
		$fields = array(
			array("file_identifier"		,"unsigned integer"	,"NOT NULL"	,"auto_increment"),
			array("file_label"			,"varchar(255)"		,"NULL"		,"default ''"),
			array("file_name"			,"varchar(255)"		,"NOT NULL"	,"default ''"),
			array("file_directory"		,"unsigned integer"	,"NOT NULL"	,"default '0'"),
			array("file_mime"			,"varchar(50)"		,"NULL"		,"default ''"),
			array("file_creation_date"	,"datetime"			,"" 		,"default NULL"),
			array("file_client"			,"unsigned integer"	,"NOT NULL"	,"default '0'"),
			array("file_size"			,"varchar(50)"		,"NOT NULL"	,"default ''"),
			array("file_width"			,"varchar(5)"		,"NOT NULL"	,"default ''"),
			array("file_height"			,"varchar(5)"		,"NOT NULL"	,"default ''"),
			array("file_user"			,"unsigned integer"	,"NOT NULL"	,"default '0'"),
			array("file_description"	,"text"				,""			,"default ''"),
			array("file_md5_tag"		,"varchar(32)"		,""			,"default ''"),
			array("file_dl_sec"			,"varchar(20)"		,""			,"default ''"),
			array("file_data"			,"blob"				,""			,"default ''")
//			array("file_user"			,"unsigned integer"	,"NOT NULL"	,"default '0'"),
		);
		$primary ="file_identifier";
		$tables[count($tables)] = array("file_info", $fields, $primary);
		
		$fields = array(
			array("file_identifier"		,"unsigned integer"	,"NOT NULL"	,"default '0'"),
			array("trans_identifier"	,"unsigned integer"	,"NOT NULL"	,"default '0'"),
			array("client_identifier"	,"unsigned integer"	,"NOT NULL"	,"default '0'"),
			array("file_rank"			,"unsigned integer"	,"NOT NULL"	,"default '0'")
		);

		$primary ="";
		$tables[count($tables)] = array("file_access_to_page", $fields, $primary);
		/*************************************************************************************************************************
        * allow linking of files to other module objects
        *************************************************************************************************************************/
		$fields = array(
			array("fto_identifier"	,"unsigned integer"	,"NOT NULL"	,"auto_increment"),
			array("fto_object"		,"unsigned integer"	,"NOT NULL"	,"default '0'"),
			array("fto_client"		,"unsigned integer"	,"NOT NULL"	,"default '0'"),
			array("fto_file"		,"unsigned integer"	,"NOT NULL"	,"default '0'"),
			array("fto_rank"		,"unsigned integer"	,"NOT NULL"	,"default '0'"),
			array("fto_module"		,"varchar(255)"	,""	,"default ''"),
			array("fto_title"		,"varchar(255)"	,""	,"default ''")
		);
		$primary ="fto_identifier";
		$tables[count($tables)] = array("file_to_object", $fields, $primary);
		/*************************************************************************************************************************
        * store file download data
        *************************************************************************************************************************/
		$fields = array(
			array("file_identifier"		,"unsigned integer"	,"NOT NULL"	,"default '0'"),
			array("user_identifier"		,"unsigned integer"	,"NOT NULL"	,"default '0'"),
			array("client_identifier"	,"unsigned integer"	,"NOT NULL"	,"default '0'"),
			array("download_time"		,"datetime"			,"NULL"		,"default ''")
		);
		$primary ="";
		$tables[count($tables)] = array("file_downloads", $fields, $primary);

		$fields = array(
			array("fi_identifier"		,"unsigned integer"	,"NOT NULL"	,"auto_increment"),
			array("fi_menu_only"		,"unsigned integer"	,"NOT NULL"	,"default '0'"),	// 0 = available on pages (leaf nodes)
			array("fi_client"			,"unsigned integer"	,"NOT NULL"	,"default '0'"),
			array("fi_display"			,"varchar(255)"		,"NOT NULL"	,"default 'List'"),	// display option (overrides syspref)
			array("fi_set_inheritance"	,"unsigned integer"	,"NOT NULL"	,"default '0'"),
			array("fi_all_locations"	,"unsigned integer"	,"NOT NULL"	,"default '0'"),
			array("fi_status"			,"unsigned integer"	,"NOT NULL"	,"default '0'"),
			array("fi_label"			,"varchar(255)"		,"NOT NULL"	,"default ''"),
			array("fi_date_created"		,"datetime"			,"NOT NULL"	,"default ''"),
			array("fi_grouping"			,"unsigned integer"	,"NOT NULL"	,"default '0'")
		);

		$primary ="fi_identifier";
		$tables[count($tables)] = array("file_list", $fields, $primary);

		return $tables;
		//file_associations
	}
	

	/**
	* call the initialisation function only when this module is created
	*/
	function create_client_details($parameters){
	}
		

}
?>